<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>疫情柱状图数据</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{/echarts/china.js}"></script>
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
</head>
<body class="childrenBody">
    <div>
        <!-- 内容主体区域 -->
        <div>
            <div id="main" style="width: 1000px;height:600px;"></div>
        </div>
    </div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
        var option = {
            xAxis: {
                type: 'category',
                data:  []
            },
            yAxis: {
                type: 'value'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            series: [
                {
                    data: [],
                    type: 'bar'
                }
            ]
        };


        $.ajax({
            url: "/api/queryBar",
            method: "GET",
            dataType: "JSON",
            success: function (data) {
                myChart.setOption({
                    xAxis: {
                        type: 'category',
                        data:  data.data.cityList
                    },
                    series: [
                        {
                            data: data.data.dataList,
                            type: 'bar'
                        }
                    ]

                })
            }
        })
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option,true);
    </script>
</body>
</html>